#include <stdio.h>
#include <stdlib.h>
#include <math.h>

#include <sim_utils.h>

void load_simulation( char *filename, sim_p *S, double *phcrd )
{
	FILE *sfile;
	char  sfile_name[128];
	sprintf( sfile_name, "%s_init.bin", filename );

	sfile = fopen( sfile_name, "rb" );
	
	fread( S, sizeof(sim_p), 1, sfile);
	
	long N_nm = S->N_nm_pcles;
	long N_mm = S->N_mm_pcles;
	
	//Debug
	printf( "%ld %ld\n", N_nm, N_mm);
	
	phcrd = (double *)malloc( sizeof(double)*7*(N_nm+N_mm) );
	fread( phcrd, sizeof(double), 7*(N_nm+N_mm), sfile );
	
	//Debug
	for( int i=0; i<(N_nm+N_mm); i++ )
	{
		for( int j=0; j<7; j++ )
			printf( "%e ", phcrd[j+i*7] );
	
		puts("");
	}
}

int main( void )
{
	char filename[128] = "sim_001";
	
	
	sim_p S1;
	double *S1_ph;
	
	load_simulation( "sim_001", &S1, S1_ph );
	
	return 0;
}
